// Author: Ivan Kazmenko (gassa@mail.ru)
// Generator for problem "double"
module gen;
import std.algorithm;
import std.ascii;
import std.conv;
import std.exception;
import std.format;
import std.random;
import std.range;
import std.stdio;

immutable string testFormat = "%03d";
enum generateAnswers = false;

immutable int minLen =  1;
immutable int maxLen = 20;

struct Test
{
	string fullName;

	string comment;

	void validate () const
	{
		enforce (minLen <= fullName.length &&
		    fullName.length <= maxLen);
		enforce (fullName.all !(isLower));
		foreach (pos; 2..fullName.length)
		{
			enforce (fullName[pos - 2] != fullName[pos] ||
			    fullName[pos - 1] != fullName[pos]);
		}
	}

	void print (File f) const
	{
		f.writeln (fullName);
	}

	string log () const
	{
		return format ("%s (%s)", comment, fullName);
	}
}

Test [] tests;

void printAllTests ()
{
	foreach (testNumber, test; tests)
	{
		test.validate ();
		auto testString = format (testFormat, testNumber + 1);
		auto f = File (testString, "wt");
		test.print (f);
		static if (generateAnswers)
		{
			auto g = File (testString ~ ".a", "wt");
			test.printAnswer (g);
		}
		writeln (testString, ": ", test.log ());
	}
}

Mt19937 rndLocal;

void main ()
{
	rndLocal.seed (157_159_002);

	tests ~= Test ("assessee", "example test 1");
	tests ~= Test ("banana", "example test 2");

	tests ~= Test ("aardvark", "small test 1");
	tests ~= Test ("a", "small test 2");

	tests ~= Test ("bookkeeping", "general test 1");
	tests ~= Test ("squirrelled", "general test 2");
	tests ~= Test ("raccoonnookkeeper", "general test 3");
	tests ~= Test ("hubbubbubboo", "general test 4");

	tests ~= Test ("reindustrializations", "large test 1");
	tests ~= Test ("undiscriminatingness", "large test 2");
	tests ~= Test ("oophorosalpingectomy", "large test 3");
	tests ~= Test ("flooddoorroommasters", "large test 4");

	printAllTests ();
}
